<?php
namespace TinyPHP\DB;
/*
 *
 * 数据工厂
 * Created by tiny
 * User: tiny
 * Date: 16/06/23
 * E-mail: mountaingiant@163.com
 *
 * */
class Db{
    public static function factor($dbConfigKey='DB_CONFIG'){
        //根据参数选择加载不同的数据库配置
        $config = getConfig($dbConfigKey);
        $dbType = strtolower($config['DB_TYPE']);
        switch($dbType){
            case 'mysql':
                $className = 'Mysql';
                break;
            default:
                exit('Error: DataBase Type');
        }
        $className = 'TinyPHP\DB\\'.$className;
        return new $className($dbConfigKey);
    }
}